package com.woniuxy.educationplatform.mapper;

import com.woniuxy.educationplatform.bean.LiveBean;
import com.woniuxy.educationplatform.bean.ProjectBean;
import com.woniuxy.educationplatform.bean.TeacherBean;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.Date;
import java.util.List;

@Mapper
public interface LiveMapper {

    @Results({
            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property = "liveName", column = "live_name", javaType = String.class),
            @Result(property = "createTime", column = "create_time", javaType = Date.class),
            @Result(property = "status", column = "status", javaType = Long.class),
            @Result(property = "ltype", column = "ltype", javaType = Long.class),
            @Result(property = "teacherName", column = "teacher_name", javaType = String.class)
    })
    @Select("select * from live")
    List<LiveBean> findAll();


    @Results({
            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property = "liveName", column = "live_name", javaType = String.class),
            @Result(property = "createTime", column = "create_time", javaType = Date.class),
            @Result(property = "status", column = "status", javaType = Long.class),
            @Result(property = "ltype", column = "ltype", javaType = Long.class),
            @Result(property = "teacherName", column = "teacher_name", javaType = String.class)
    })
    @Select("select * from live where id = #{id}")
    LiveBean findById(Long id);

    @Insert("insert into live (live_name,create_time,status,teacher_name,ltype) values(#{l.liveName},#{l.createTime},1,#{l.teacherName},#{l.ltype})")
    void saveLiveBean(@Param("l") LiveBean liveBean);

    List<LiveBean> findOneByCondition(@Param("l") LiveBean liveBean);

    @Update("update live set status = #{status} where id = #{id}")
    void changeStatus(Long status,Long id);

    @Delete("delete from live where id = #{id}")
    void delete(Long id);
}

